import React, { lazy } from "react";
import { createBrowserRouter } from "react-router-dom";
import {
  AppOutline,
  MessageOutline,
  UnorderedListOutline,
  UserOutline,
} from "antd-mobile-icons";

//引入路由组件
const Login = lazy(() => import("../pages/Login"));
//const Login = lazy(() => import("../pages/Login/LoginTel"));
const Register = lazy(() => import("../pages/Register"));
const Mainlayout = lazy(() => import("../pages/Mainlayout"));
const Home = lazy(() => import("../pages/Home"));
const Props = lazy(() => import("../pages/Props"));
const Message = lazy(() => import("../pages/Message"));
const User = lazy(() => import("../pages/User"));
const Detail = lazy(() => import("../pages/Detail"));
const NotFound = lazy(() => import("../pages/404"));
const Order = lazy(() => import("../pages/Order"));
const Success = lazy(() => import("../pages/Success"));
const SelSeat = lazy(() => import("../pages/SelSeat"));

//配置二级路由
export const routeChildList = [
  {
    path: "/",
    element: <Home />,
    title: "首页",
    icon: <AppOutline />,
  },
  {
    path: "/props",
    element: <Props />,
    title: "分类",
    icon: <UnorderedListOutline />,
  },
  {
    path: "/message",
    element: <Message />,
    title: "消息",
    icon: <MessageOutline />,
  },
  {
    path: "/user",
    element: <User />,
    title: "个人中心",
    icon: <UserOutline />,
  },
];

//配置一级路由
export const routerList = createBrowserRouter([
  {
    path: "/",
    element: <Mainlayout />,
    children: routeChildList,
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "/register",
    element: <Register />,
  },
  {
    path: "/detail/:id",
    element: <Detail />,
  },
  {
    path: "/order",
    element: <Order />,
  },
  {
    path: "/selseat",
    element: <SelSeat />,
  },
  {
    path: "/success",
    element: <Success />,
  },
  {
    path: "*",
    element: <NotFound />,
  },
]);
